﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using NS.BLL.Systems;
using NS.Utilities;

public partial class WebMaster : System.Web.UI.MasterPage
{
    protected void Page_Init(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(CookieHelper.GetValue("uid")))
        {
            MessageBox.AppendScript(this, "alert('登陆超时！');parent.location.href = '../Login.aspx';");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.QueryString["mid"] != null)
            {
                PageTitle.Text = CreatePath(Request.QueryString["mid"]);
            }
        }
    }

    private string CreatePath(string ParentID)
    {
        StringBuilder MenuPath = new StringBuilder();
        NS.Model.Systems.Menu Model = MenuService.Select(Convert.ToInt64(ParentID));
        if (Model != null)
        {
            string[] MyArray = (Model.ParentPath + "," + ParentID).Split(',');
            foreach (string MenuID in MyArray)
            {
                if (MenuID != "0")
                {
                    string strMenuName = UtilityService.GetFieldValueByPK("Menu", "MenuName", "MenuID", MenuID)[0].ToString();
                    MenuPath.Append("<i class=\"arrow\"></i><span>" + strMenuName + "</span>");
                }
            }
        }
        return MenuPath.ToString();
    }
}
